//////////////////////////////////////////////////////////////////////////
///	\file:	TPView.h
///	Copyright (Home) 2010 - All Rights Reserved
///	Author:	Robert.Ma
///	Date:	[2010/01/31]
///	Description:
///		interface of the CTPView class
//////////////////////////////////////////////////////////////////////////
#pragma once
#include <atlddx.h>
#include <atlcrack.h>

#include "VolTrackbar.h"
#include "cebmpbutton.h"

//////////////////////////////////////////////////////////////////////////
///	\class	CTPView
///	\brief	View of player.
class CTPView :
			public CAxDialogImpl<CTPView>,
			public CWinDataExchange<CTPView>
{
public:
	enum { IDD = IDD_TIMEPLAYER_FORM };

	BOOL PreTranslateMessage(MSG* pMsg);

	BEGIN_MSG_MAP(CTPView)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		NOTIFY_HANDLER(IDC_TRACK_LIST, NM_DBLCLK, OnNMDblclkTrackList)
		COMMAND_HANDLER(IDC_PAUSE, BN_CLICKED, OnBnClickedPause)
		COMMAND_HANDLER(IDC_NEXT, BN_CLICKED, OnBnClickedNext)
		COMMAND_HANDLER(IDC_PLAY, BN_CLICKED, OnBnClickedPlay)
		COMMAND_HANDLER(IDC_PREV, BN_CLICKED, OnBnClickedPrev)
	END_MSG_MAP()

	BEGIN_DDX_MAP(CTPView)
		DDX_CONTROL_HANDLE(IDC_TRACK_LIST, m_wndTrackList)
		DDX_CONTROL_HANDLE(IDC_NUM, m_wndNumStatic)
	END_DDX_MAP()

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnNMDblclkTrackList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);

	LRESULT OnBnClickedPause(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedNext(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedPlay(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedPrev(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	void UpdateList();
	int GetCurTrack() const;

	void UpdateTime();

private:
	CListViewCtrl	m_wndTrackList;
	CVolTrackbar	m_wndVolTrack;
	CStatic			m_wndNumStatic;

	CBMPButton	m_wndPrevBtn;
	CBMPButton	m_wndPlayBtn;
	CBMPButton	m_wndPauseBtn;
	CBMPButton	m_wndNextBtn;

	CImageList	m_ImageList;
};
